Popular Searches
Popular Course Categories
Popular Courses

HTML Reports

Screenshots & Reporting

HTML Reports in Selenium Automation

HTML Reports are web-based test reports used in Selenium automation frameworks to present test execution results in a clear, readable, and interactive format. They provide information about passed, failed, skipped, and executed test cases along with execution details, logs, screenshots, timestamps, error messages, and other useful test evidence.

In a Selenium automation framework, HTML reports make it easier for testers, developers, QA leads, managers, and other stakeholders to understand the overall health of an automated test suite without reading the source code or console output.

HTML reports are commonly integrated with testing frameworks such as TestNG, JUnit, and PyTest and can be generated using reporting libraries and tools such as ExtentReports, Allure, and built-in or plugin-based reporting systems.

Course Resource: Selenium Training | Register for Course Demo


1. What are HTML Reports?

An HTML report is a test execution report generated in HTML format that can be opened in a web browser. It converts raw test execution information into a structured and visually understandable report.

A typical HTML report can contain:

  • Total number of test cases.
  • Passed test cases.
  • Failed test cases.
  • Skipped test cases.
  • Execution duration.
  • Test case names.
  • Test steps.
  • Failure messages.
  • Exception details.
  • Execution timestamps.
  • Screenshots.
  • Logs.
  • Browser and environment information.
  • Author information.
  • Test categories.
  • Build information.


2. Why are HTML Reports Important?

Automation suites can execute hundreds or thousands of test cases. Console output alone can become difficult to analyze. HTML reports organize the execution information into a readable format.

  • Provides a visual representation of test results.
  • Makes failures easier to identify.
  • Provides execution history and evidence.
  • Helps debugging failed tests.
  • Can contain screenshots of failed steps.
  • Helps QA teams communicate test results.
  • Can be shared with developers and stakeholders.
  • Can be integrated with CI/CD pipelines.
  • Improves automation framework maintainability.
  • Provides useful execution statistics.


3. HTML Report Flow

Test Data

    |

    v

TestNG / JUnit / PyTest

    |

    v

Selenium WebDriver

    |

    v

Test Execution

    |

    +------------------+

    |                  |

    v                  v

Pass               Failure

    |                  |

    |                  +----> Exception

    |                  |

    |                  +----> Screenshot

    |                  |

    |                  +----> Logs

    |                  |

    +---------+--------+

              |

              v

       Reporting Library

              |

              v

         HTML Report

              |

              v

       Open in Browser


4. Information Available in an HTML Report

InformationDescription
Total TestsTotal number of executed test cases
PassedNumber of successful tests
FailedNumber of failed tests
SkippedNumber of skipped tests
DurationTotal execution time
Test NameName of the executed test
ErrorFailure or exception information
ScreenshotVisual evidence captured during execution
LogsExecution information and debugging details
EnvironmentBrowser, operating system, build, or environment information


5. HTML Reports in Selenium

Selenium WebDriver itself performs browser automation but does not act as a complete test reporting framework. Reporting is generally handled by the testing framework and reporting libraries used around Selenium.

A typical Selenium framework contains the following components:

Selenium WebDriver

        +

TestNG

        +

Reporting Library

        +

Logging

        +

Screenshot Utility

        |

        v

Complete Automation Report


6. TestNG and HTML Reports

TestNG provides test execution and result information that can be used for reporting. TestNG also produces HTML result files when tests are executed.

TestNG reports can provide information such as:

  • Passed methods.
  • Failed methods.
  • Skipped methods.
  • Test execution duration.
  • Methods executed under different test groups.
  • Configuration method results.

For more customized and visually rich reporting, automation frameworks commonly integrate dedicated reporting libraries.


7. Basic TestNG Test Example

import org.testng.Assert;

import org.testng.annotations.Test;

 

public class LoginTest {

 

    @Test

    public void validLoginTest() {

        System.out.println("Executing valid login test");

        Assert.assertTrue(true);

    }

 

    @Test

    public void invalidLoginTest() {

        System.out.println("Executing invalid login test");

        Assert.assertTrue(false);

    }

}

When this test suite executes, TestNG records the execution status and generates test result information that can be viewed through its reporting output.


8. What is ExtentReports?

ExtentReports is a reporting library commonly used in Java-based automation frameworks to create detailed and customizable HTML reports.

It can be used to record:

  • Test names.
  • Test status.
  • Test steps.
  • Pass messages.
  • Failure messages.
  • Warning messages.
  • Exceptions.
  • Screenshots.
  • Execution metadata.
  • Categories.
  • Authors.


9. ExtentReports Architecture

TestNG Test

     |

     v

ExtentTest

     |

     v

Test Steps

     |

     +---- PASS

     |

     +---- FAIL

     |

     +---- INFO

     |

     +---- WARNING

     |

     v

ExtentReports

     |

     v

HTML Report


10. Maven Dependency for ExtentReports

In a Maven-based Java automation project, the reporting library can be added as a project dependency. The exact version should be selected according to the project's current compatibility requirements.

<dependency>

    <groupId>com.aventstack</groupId>

    <artifactId>extentreports</artifactId>

    <version>VERSION</version>

</dependency>

After adding the dependency, Maven downloads the required reporting library and its dependencies.


11. Creating an ExtentReports Object

import com.aventstack.extentreports.ExtentReports;

import com.aventstack.extentreports.reporter.ExtentSparkReporter;

 

ExtentSparkReporter reporter =

        new ExtentSparkReporter("reports/TestReport.html");

 

ExtentReports extent = new ExtentReports();

 

extent.attachReporter(reporter);

The reporter defines the report output location while the ExtentReports object manages the reporting lifecycle.


12. Creating a Test in ExtentReports

ExtentTest test = extent.createTest("Login Test");

 

test.info("Opening login page");

test.pass("Login page opened successfully");

The test object represents an individual test entry inside the generated report.


13. Logging Test Steps

Reporting becomes more useful when individual automation steps are logged.

test.info("Opening application");

 

test.info("Entering username");

 

test.info("Entering password");

 

test.info("Clicking login button");

 

test.pass("Login completed successfully");

These messages help users understand what happened during execution.


14. Logging Passed Tests

test.pass("Login test passed successfully");

The pass() method records a successful step or test status in the report.


15. Logging Failed Tests

test.fail("Login test failed");

When a test fails, the failure message can be added to the report together with exception information and screenshots.


16. Logging Warnings

test.warning("Login response was slower than expected");

Warnings can be used to record conditions that are important but do not necessarily cause the test to fail.


17. Logging Information

test.info("Starting browser session");

test.info("Navigating to application");

Information messages are useful for documenting test execution steps.


18. Capturing Screenshots

Screenshots are extremely useful in Selenium reports because they provide visual evidence of the browser state at a particular point in execution.

File screenshot =

        ((TakesScreenshot) driver)

        .getScreenshotAs(OutputType.FILE);

The screenshot can then be stored and attached to the report.


19. Screenshot Utility

A reusable screenshot utility can be created to avoid duplicating screenshot code throughout the framework.

public static String captureScreenshot(

        WebDriver driver,

        String testName) {

 

    TakesScreenshot ts =

            (TakesScreenshot) driver;

 

    File source =

            ts.getScreenshotAs(OutputType.FILE);

 

    String path =

            "screenshots/" + testName + ".png";

 

    File destination =

            new File(path);

 

    try {

        Files.copy(

            source.toPath(),

            destination.toPath(),

            StandardCopyOption.REPLACE_EXISTING

        );

    } catch (IOException e) {

        e.printStackTrace();

    }

 

    return path;

}


20. Attaching Screenshot to Report

String screenshotPath =

        captureScreenshot(driver, "LoginFailure");

 

test.fail(

    "Login test failed",

    MediaEntityBuilder

        .createScreenCaptureFromPath(screenshotPath)

        .build()

);

This allows the report to display or link to visual evidence associated with the failure.


21. HTML Report with TestNG Lifecycle

A common reporting design uses TestNG configuration methods to initialize the report before execution and flush the report after execution.

@BeforeSuite

public void startReport() {

    // Initialize reporting

}

 

@AfterSuite

public void endReport() {

    // Write report to disk

}

This ensures that the reporting lifecycle is connected to the overall test suite lifecycle.


22. Complete Basic ExtentReports Example

import com.aventstack.extentreports.ExtentReports;

import com.aventstack.extentreports.ExtentTest;

import com.aventstack.extentreports.reporter.ExtentSparkReporter;

import org.testng.Assert;

import org.testng.annotations.AfterSuite;

import org.testng.annotations.BeforeSuite;

import org.testng.annotations.Test;

 

public class ReportTest {

 

    static ExtentReports extent;

    static ExtentTest test;

 

    @BeforeSuite

    public void startReport() {

        ExtentSparkReporter reporter =

                new ExtentSparkReporter(

                    "reports/TestReport.html"

                );

 

        extent = new ExtentReports();

        extent.attachReporter(reporter);

    }

 

    @Test

    public void loginTest() {

 

        test = extent.createTest("Login Test");

 

        test.info("Starting login test");

 

        test.info("Entering username");

 

        test.info("Entering password");

 

        test.info("Clicking login button");

 

        Assert.assertTrue(true);

 

        test.pass("Login test passed");

    }

 

    @AfterSuite

    public void endReport() {

        extent.flush();

    }

}


23. Why Use extent.flush()?

The flush() method writes the collected test information to the configured report output.

extent.flush();

If the reporting lifecycle is not completed correctly, the report may not contain all information generated during the test execution.


24. Report Generation Flow

Start Test Suite

      |

      v

Initialize Reporter

      |

      v

Create Test

      |

      v

Execute Selenium Steps

      |

      v

Log Test Information

      |

      +------> Pass

      |

      +------> Fail

      |

      +------> Screenshot

      |

      +------> Exception

      |

      v

Complete Test

      |

      v

Flush Report

      |

      v

Open HTML File


25. HTML Reports and Failed Tests

A useful report should provide enough information to understand why a test failed.

For a failed Selenium test, the report can include:

  • Test case name.
  • Browser name.
  • Environment.
  • Test step that failed.
  • Exception message.
  • Stack trace.
  • Screenshot.
  • Execution time.
  • Relevant test data.
  • Application URL.


26. Reporting Exceptions

try {

    // Selenium test steps

} catch (Exception e) {

 

    test.fail(

        "Test failed: " + e.getMessage()

    );

 

    throw e;

}

Recording the exception in the report makes debugging easier.


27. HTML Reports with Assertions

String actualTitle = driver.getTitle();

 

String expectedTitle = "Dashboard";

 

try {

 

    Assert.assertEquals(actualTitle, expectedTitle);

 

    test.pass("Page title validation passed");

 

} catch (AssertionError e) {

 

    test.fail("Page title validation failed");

 

    throw e;

}


28. Reporting Login Test Results

@Test

public void loginTest() {

 

    ExtentTest test =

            extent.createTest("Valid Login Test");

 

    test.info("Opening login page");

 

    driver.findElement(By.id("username"))

            .sendKeys("admin");

 

    test.info("Username entered");

 

    driver.findElement(By.id("password"))

            .sendKeys("password");

 

    test.info("Password entered");

 

    driver.findElement(By.id("loginButton"))

            .click();

 

    test.info("Login button clicked");

 

    test.pass("Login test completed");

}


29. HTML Reports with Page Object Model

HTML reporting works well with the Page Object Model because page interaction logic and reporting logic can be kept separate.

Test Class

    |

    +---- Report Logs

    |

    v

Page Object

    |

    +---- Login Actions

    |

    v

Selenium WebDriver

    |

    v

Application

The test class can report business-level actions while the Page Object class handles element interaction.


30. Reporting in a POM Framework

public class LoginTest {

 

    @Test

    public void loginTest() {

 

        ExtentTest test =

                extent.createTest("Login Test");

 

        test.info("Opening login page");

 

        LoginPage loginPage =

                new LoginPage(driver);

 

        loginPage.enterUsername("admin");

 

        test.info("Username entered");

 

        loginPage.enterPassword("password");

 

        test.info("Password entered");

 

        loginPage.clickLogin();

 

        test.pass("Login action completed");

    }

}


31. HTML Reports and Test Data

When Data Providers are used, every test invocation can be associated with its input data.

@DataProvider(name = "loginData")

public Object[][] loginData() {

    return new Object[][] {

        {"admin", "admin123"},

        {"manager", "manager123"},

        {"employee", "employee123"}

    };

}

 

@Test(dataProvider = "loginData")

public void loginTest(

        String username,

        String password) {

 

    ExtentTest test =

            extent.createTest(

                "Login Test - " + username

            );

 

    test.info(

        "Testing login for: " + username

    );

}

Sensitive values such as passwords should not be written into reports in plain text.


32. HTML Reports and Data Providers

Data Providers are useful when the same Selenium workflow must be tested with multiple inputs. Reporting should identify the data set associated with each invocation.

Data Provider

      |

      +---- User 1

      |       |

      |       +---- Test Result

      |

      +---- User 2

      |       |

      |       +---- Test Result

      |

      +---- User 3

              |

              +---- Test Result


33. HTML Reports and Cross-Browser Testing

Cross-browser frameworks can include browser information in reports so that failures can be associated with the correct browser.

test.info("Browser: Chrome");

test.info("Environment: QA");

test.info("Test: Login");

For larger frameworks, browser and environment information can be added automatically through reusable reporting utilities.


34. HTML Reports and Environment Information

Reports can include information about the environment in which the tests were executed.

Environment DetailExample
EnvironmentQA
BrowserChrome
Operating SystemWindows
Application URLhttps://qa.example.com
BuildBuild-102
Execution TypeRegression


35. HTML Reports and Test Categories

Large automation projects may categorize tests to make reports easier to analyze.

Common categories include:

  • Smoke.
  • Regression.
  • Sanity.
  • Functional.
  • Critical.
  • Login.
  • Checkout.
  • Search.
  • API.


36. HTML Reports and Authors

Test reports can include information about test ownership or authorship where supported by the reporting framework.

test.assignAuthor("Automation Team");

This can help teams identify ownership of test scenarios in large automation projects.


37. HTML Reports and Test Descriptions

ExtentTest test =

    extent.createTest(

        "Login Test",

        "Validate login using valid credentials"

    );

Test descriptions provide additional context about the purpose of a test case.


38. HTML Reports and Execution Time

Execution time is useful for identifying slow tests and monitoring automation suite performance.

long startTime = System.currentTimeMillis();

 

// Execute test

 

long endTime = System.currentTimeMillis();

 

long duration =

        endTime - startTime;

 

test.info(

    "Execution time: " + duration + " ms"

);


39. HTML Reports and Screenshots on Failure

One of the most useful reporting practices is automatically capturing a screenshot when a test fails.

@AfterMethod

public void captureFailure(

        ITestResult result) {

 

    if (result.getStatus()

            == ITestResult.FAILURE) {

 

        String testName =

                result.getName();

 

        String screenshotPath =

                captureScreenshot(

                    driver,

                    testName

                );

 

        // Attach screenshot to report

    }

}


40. TestNG ITestResult

ITestResult provides information about the result of an individual TestNG test invocation.

It can be used to determine whether a test:

  • Passed.
  • Failed.
  • Was skipped.
  • Returned an exception.
  • Has a particular test method name.


41. Capturing Screenshot Automatically After Failure

@AfterMethod

public void tearDown(ITestResult result) {

 

    if (result.getStatus()

            == ITestResult.FAILURE) {

 

        String testName =

                result.getMethod()

                       .getMethodName();

 

        String screenshot =

                captureScreenshot(

                    driver,

                    testName

                );

 

        System.out.println(

            "Screenshot: " + screenshot

        );

    }

 

    if (driver != null) {

        driver.quit();

    }

}


42. HTML Reports and Logging

Reporting and logging serve related but different purposes.

ReportingLogging
Summarizes test executionRecords detailed application/test events
Designed for results and analysisDesigned for debugging and diagnostics
Often contains screenshotsOften contains technical messages
Used by testers and stakeholdersUsed heavily by developers and automation engineers


43. HTML Reports and Log4j

Log4j or another logging framework can be used alongside HTML reporting.

logger.info("Opening login page");

 

logger.info("Entering username");

 

logger.info("Clicking login button");

 

test.info("Login workflow executed");

Logging provides technical diagnostic information while the HTML report provides an organized test-result view.


44. HTML Reports and Allure

Allure Report is another reporting solution used with automated testing frameworks. It provides interactive test result visualization and can display test steps, attachments, categories, timing information, and other execution details.

Allure can be integrated with different testing technologies and is often used when teams need rich, interactive test reporting.


45. ExtentReports vs Allure

FeatureExtentReportsAllure
HTML ReportingYesYes
Test StepsSupportedSupported
ScreenshotsSupportedSupported
AttachmentsSupportedSupported
Test CategoriesSupportedSupported
Framework IntegrationCommon in Java automationSupports multiple testing ecosystems


46. HTML Reports and CI/CD

HTML reports become especially useful when Selenium tests run automatically through CI/CD pipelines.

Developer Commit

       |

       v

Git Repository

       |

       v

Jenkins / CI Server

       |

       v

Maven Build

       |

       v

TestNG

       |

       v

Selenium Tests

       |

       v

HTML Report

       |

       v

Build Result / Test Evidence


47. HTML Reports in Jenkins

Jenkins can execute automated Selenium tests and publish or archive generated test reports depending on the configured plugins and pipeline setup.

A typical flow is:

  1. Developer pushes code.
  2. Jenkins starts a build.
  3. Maven installs dependencies.
  4. TestNG starts test execution.
  5. Selenium performs browser automation.
  6. Reporting library generates the report.
  7. Jenkins stores or publishes the report.
  8. Team members review the execution result.


48. HTML Reports with Maven

Maven is commonly used to build and execute Java Selenium automation projects.

mvn clean test

The reporting framework can generate the HTML report during or after the test execution depending on its configuration.


49. Report Folder Structure

A Selenium automation project can organize reports and screenshots in separate folders.

project

|-- src

|   |-- test

|       |-- java

|           |-- tests

|           |-- pages

|           |-- utilities

|

|-- reports

|   |-- TestReport.html

|   |-- screenshots

|       |-- LoginTest.png

|       |-- SearchTest.png

|

|-- pom.xml

|-- testng.xml


50. Centralized Report Manager

Large frameworks should avoid creating reporting objects independently inside every test class. A centralized reporting utility can manage report initialization and test creation.

public class ReportManager {

 

    private static ExtentReports extent;

 

    public static ExtentReports getReport() {

 

        if (extent == null) {

 

            ExtentSparkReporter reporter =

                new ExtentSparkReporter(

                    "reports/TestReport.html"

                );

 

            extent = new ExtentReports();

 

            extent.attachReporter(reporter);

        }

 

        return extent;

    }

}


51. Creating Tests Through Report Manager

ExtentReports extent =

        ReportManager.getReport();

 

ExtentTest test =

        extent.createTest("Login Test");

 

test.info("Starting login test");

This approach helps keep reporting logic reusable throughout the automation framework.


52. Thread Safety in Reporting

When Selenium tests execute in parallel, reporting objects must be designed carefully. A framework should avoid unsafe sharing of test objects between concurrent test executions.

A common approach is to use thread-aware reporting mechanisms or a framework utility designed for parallel execution.

Thread 1

   |

   +---- Test A

   |

   +---- Report Entry A

 

Thread 2

   |

   +---- Test B

   |

   +---- Report Entry B


53. HTML Reports for Parallel Execution

Parallel execution can significantly increase reporting complexity because multiple test cases may execute simultaneously.

The report should clearly associate:

  • Test name.
  • Thread.
  • Browser.
  • Environment.
  • Test data.
  • Screenshot.
  • Failure message.


54. HTML Reports for Regression Testing

Regression testing can contain a large number of test cases. HTML reports provide a convenient summary of the regression suite.

CategoryExecutedPassedFailedSkipped
Login10910
Search151500
Cart121011
Checkout8710

The values above are an example of how report summaries can be organized.


55. HTML Reports for Smoke Testing

Smoke tests are often executed before larger regression suites. An HTML report can quickly show whether critical functionality is working.

Smoke Suite

    |

    +---- Login       PASS

    |

    +---- Search      PASS

    |

    +---- Cart        PASS

    |

    +---- Checkout    FAIL

    |

    v

Smoke Report


56. HTML Reports for Failed Test Analysis

A good report should allow an automation engineer to move from a failure summary to the exact failed step and supporting evidence.

Failed Test

    |

    v

Failed Step

    |

    v

Exception

    |

    v

Stack Trace

    |

    v

Screenshot

    |

    v

Application State

    |

    v

Root Cause Investigation


57. Naming Test Reports

Report filenames should be meaningful and should avoid unnecessary overwriting when multiple builds are executed.

TestReport.html

RegressionReport.html

SmokeReport.html

LoginReport.html

For CI environments, reports can also include build numbers or timestamps.


58. Timestamp-Based Report Names

String timestamp =

        new SimpleDateFormat(

            "yyyyMMdd_HHmmss"

        ).format(new Date());

 

String reportPath =

        "reports/TestReport_" +

        timestamp +

        ".html";

This approach can help preserve reports from multiple executions.


59. Report Metadata

Reports can contain metadata that helps identify the execution environment.

extent.setSystemInfo(

    "Environment",

    "QA"

);

 

extent.setSystemInfo(

    "Browser",

    "Chrome"

);

 

extent.setSystemInfo(

    "OS",

    "Windows"

);

 

extent.setSystemInfo(

    "Automation",

    "Selenium WebDriver"

);


60. HTML Report Dashboard

A report dashboard generally provides a high-level summary before allowing the user to inspect individual tests.

+---------------------------------------+

|          AUTOMATION REPORT            |

+---------------------------------------+

| Total: 100 | Pass: 90 | Fail: 7      |

| Skip: 3   | Duration: 25 min          |

+---------------------------------------+

| Test Categories                       |

| Login      : PASS                     |

| Search     : PASS                     |

| Cart       : FAIL                     |

| Checkout   : PASS                     |

+---------------------------------------+

| Detailed Test Results                 |

+---------------------------------------+


61. Customizing HTML Reports

Reporting libraries generally provide configuration options for report titles, names, themes, metadata, document names, and other presentation-related settings.

ExtentSparkReporter reporter =

        new ExtentSparkReporter(

            "reports/SeleniumReport.html"

        );

 

reporter.config()

        .setDocumentTitle(

            "Selenium Automation Report"

        );

 

reporter.config()

        .setReportName(

            "Regression Test Report"

        );


62. Report Naming Conventions

  • Use meaningful report filenames.
  • Include suite names where useful.
  • Use timestamps for historical reports.
  • Use build numbers in CI environments.
  • Separate smoke and regression reports.
  • Keep reports in a dedicated directory.


63. HTML Reports and Screenshots Directory

Reports and screenshots should be organized consistently.

reports/

|

|-- TestReport.html

|

|-- screenshots/

|   |-- LoginTest.png

|   |-- SearchTest.png

|   |-- CheckoutTest.png

|

|-- logs/

    |-- automation.log


64. HTML Reports and Videos

For some advanced automation environments, execution videos can be generated by external browser or execution infrastructure and linked or attached to test results.

Videos can be particularly useful for analyzing intermittent failures in remote or distributed execution environments.


65. HTML Reports and Test Evidence

Test evidence may include:

  • Screenshots.
  • Logs.
  • Failure messages.
  • Browser information.
  • Application URL.
  • Test data identifiers.
  • Execution timestamps.
  • Video recordings where supported.
  • API responses where appropriate.


66. Protecting Sensitive Information in Reports

Reports are often shared with multiple people, so sensitive information should not be logged unnecessarily.

  • Do not log passwords.
  • Do not expose API keys.
  • Do not expose authentication tokens.
  • Mask sensitive test data where required.
  • Avoid storing secrets in screenshots where possible.
  • Use secure secret-management solutions for credentials.
  • Control access to reports containing sensitive information.


67. Common Mistakes in HTML Reporting

  • Forgetting to flush the report.
  • Creating a new report for every test method unnecessarily.
  • Not attaching screenshots to failures.
  • Logging sensitive credentials.
  • Using hard-coded report paths incorrectly.
  • Overwriting previous reports unintentionally.
  • Sharing reporting objects unsafely during parallel execution.
  • Not recording enough test-step information.
  • Generating reports without cleaning old artifacts.
  • Not integrating reports with CI/CD.


68. Best Practices for HTML Reports

  • Initialize the reporting system once per appropriate test suite or execution.
  • Use meaningful test names.
  • Log important test steps.
  • Capture screenshots when tests fail.
  • Include browser and environment information.
  • Keep passwords and secrets out of reports.
  • Use reusable reporting utilities.
  • Use timestamps or build numbers when historical reports are required.
  • Design reporting utilities for parallel execution.
  • Integrate reports into CI/CD workflows.
  • Keep screenshots and other artifacts organized.
  • Make failure messages descriptive.
  • Remove or archive obsolete reports according to project requirements.


69. HTML Reports vs Console Output

Console OutputHTML Report
Text-basedBrowser-based
Can become difficult to analyzeStructured and organized
Limited visual evidenceCan include screenshots
Usually temporary during executionCan be stored and shared
Less suitable for stakeholdersMore suitable for result communication
Limited navigationCan provide interactive navigation


70. HTML Reports vs TestNG Default Reports

FeatureTestNG Default ReportDedicated HTML Reporting
Basic ResultsYesYes
Custom LogsLimitedExtensive
ScreenshotsRequires additional handlingCommonly supported
CustomizationLimitedMore flexible
Visual DashboardBasicCan be highly customized
Test EvidenceBasicRich attachments possible


71. Practical Selenium Reporting Framework

selenium-project/

|

|-- src/

|   |-- test/

|       |-- java/

|           |-- tests/

|           |   |-- LoginTest.java

|           |   |-- SearchTest.java

|           |   |-- CheckoutTest.java

|           |

|           |-- pages/

|           |   |-- LoginPage.java

|           |   |-- SearchPage.java

|           |   |-- CheckoutPage.java

|           |

|           |-- utilities/

|               |-- DriverFactory.java

|               |-- ScreenshotUtil.java

|               |-- ReportManager.java

|               |-- ConfigReader.java

|

|-- reports/

|   |-- TestReport.html

|   |-- screenshots/

|

|-- logs/

|

|-- pom.xml

|-- testng.xml


72. Complete Reporting Architecture

                 Test Data

                     |

                     v

               TestNG Test

                     |

                     v

             Page Object Model

                     |

                     v

              Selenium Driver

                     |

                     v

                Web App

                     |

                     v

                Assertion

                     |

          +----------+----------+

          |                     |

        PASS                  FAIL

          |                     |

          |              Screenshot

          |                     |

          |                Exception

          |                     |

          +----------+----------+

                     |

                     v

              Report Manager

                     |

                     v

             HTML Report

                     |

          +----------+----------+

          |                     |

       Local Review          CI/CD

                                |

                                v

                         Team / Stakeholders


73. Complete Practical Example

import com.aventstack.extentreports.ExtentReports;

import com.aventstack.extentreports.ExtentTest;

import com.aventstack.extentreports.reporter.ExtentSparkReporter;

 

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

 

import org.testng.Assert;

import org.testng.annotations.*;

 

public class SeleniumReportTest {

 

    WebDriver driver;

 

    static ExtentReports extent;

    ExtentTest test;

 

    @BeforeSuite

    public void initializeReport() {

 

        ExtentSparkReporter reporter =

                new ExtentSparkReporter(

                    "reports/SeleniumReport.html"

                );

 

        extent = new ExtentReports();

 

        extent.attachReporter(reporter);

 

        extent.setSystemInfo(

            "Environment",

            "QA"

        );

 

        extent.setSystemInfo(

            "Automation",

            "Selenium WebDriver"

        );

    }

 

    @BeforeMethod

    public void setup() {

 

        driver = new ChromeDriver();

 

        driver.manage()

              .window()

              .maximize();

 

        driver.get(

            "https://example.com/login"

        );

    }

 

    @Test

    public void loginTest() {

 

        test =

            extent.createTest(

                "Valid Login Test"

            );

 

        test.info(

            "Opening login page"

        );

 

        driver.findElement(

            By.id("username")

        ).sendKeys("admin");

 

        test.info(

            "Username entered"

        );

 

        driver.findElement(

            By.id("password")

        ).sendKeys("password");

 

        test.info(

            "Password entered"

        );

 

        driver.findElement(

            By.id("loginButton")

        ).click();

 

        test.info(

            "Login button clicked"

        );

 

        Assert.assertTrue(

            driver.getTitle()

                  .contains("Dashboard")

        );

 

        test.pass(

            "Login test passed"

        );

    }

 

    @AfterMethod

    public void tearDown() {

 

        if (driver != null) {

            driver.quit();

        }

    }

 

    @AfterSuite

    public void closeReport() {

 

        extent.flush();

    }

}


74. Practical Project: Login HTML Report

Suppose an automation framework tests a login page. The framework can generate a report containing the following information:

TestStatusEvidence
Valid LoginPASSExecution log
Invalid UsernamePASSValidation message
Invalid PasswordPASSValidation message
Blank CredentialsFAILScreenshot + exception

This makes it easier to identify exactly which scenario requires investigation.


75. Practical Project: E-Commerce HTML Report

An e-commerce Selenium framework may report multiple business workflows.

E-Commerce Automation Report

|

|-- Login

|   |-- Valid Login

|   |-- Invalid Login

|

|-- Product Search

|   |-- Laptop

|   |-- Mobile

|   |-- Headphones

|

|-- Cart

|   |-- Add Product

|   |-- Remove Product

|   |-- Update Quantity

|

|-- Checkout

|   |-- Address

|   |-- Payment

|   |-- Order Confirmation

|

|-- Regression Summary


76. Reporting Workflow for Failed Selenium Tests

Test Starts

    |

    v

Browser Opens

    |

    v

Test Steps Execute

    |

    v

Assertion

    |

    +---- PASS ----> Log PASS

    |

    +---- FAIL ----> Capture Exception

                         |

                         v

                    Capture Screenshot

                         |

                         v

                    Log Failure

                         |

                         v

                    Add Evidence

                         |

                         v

                    HTML Report


77. Report Quality Checklist

  • Does every test have a meaningful name?
  • Are pass and failure statuses clearly visible?
  • Are failed steps recorded?
  • Are screenshots captured for important failures?
  • Are exceptions included?
  • Is browser information available?
  • Is environment information available?
  • Are sensitive credentials hidden?
  • Can reports be accessed from CI/CD?
  • Are historical reports preserved when required?
  • Are screenshots stored in an organized directory?
  • Does the report work correctly after parallel execution?


78. Interview Questions on HTML Reports

1. What is an HTML report?

An HTML report is a browser-viewable test execution report that presents test results, logs, failures, screenshots, and other execution information in a structured format.

2. Why are HTML reports used in Selenium?

They make automation results easier to understand, analyze, debug, and share.

3. Does Selenium generate complete HTML reports by itself?

Selenium WebDriver primarily performs browser automation. Reporting is normally handled by TestNG, JUnit, PyTest, or dedicated reporting libraries.

4. What is ExtentReports?

ExtentReports is a reporting library that can generate detailed and customizable test reports for automation frameworks.

5. What is Allure?

Allure is a test reporting solution that provides interactive test-result visualization and supports steps, attachments, categories, timing, and other reporting information.

6. Why are screenshots useful in reports?

Screenshots provide visual evidence of the browser state at the time of a test step or failure.

7. What is extent.flush()?

It writes the collected ExtentReports information to the configured report output.

8. How can screenshots be captured in Selenium?

Selenium provides the TakesScreenshot interface for capturing screenshots.

9. How can screenshots be captured only when a test fails?

TestNG's ITestResult can be checked in a configuration method such as @AfterMethod to determine whether the test failed.

10. Can HTML reports be integrated with Jenkins?

Yes. Reports generated during CI execution can be archived or published using appropriate Jenkins configuration and plugins.

11. Why should passwords not be logged in reports?

Reports may be shared or stored as artifacts, so exposing passwords creates unnecessary security risk.

12. What information should a failure report contain?

A useful failure report can contain the failed step, exception, stack trace, screenshot, browser, environment, timestamp, and relevant non-sensitive test data.

13. Can HTML reports be used with Data Providers?

Yes. Each Data Provider invocation can be recorded as an individual test execution and associated with its input data.

14. Can HTML reports be used with Page Object Model?

Yes. Reporting can be maintained in test or framework utilities while Page Objects manage Selenium interactions.

15. Why is centralized reporting useful?

A centralized report manager avoids duplicated report initialization code and provides a reusable reporting mechanism for the framework.

16. How are reports useful in regression testing?

They provide a summary of large test suites and help identify failed areas that require investigation.

17. What is the difference between logs and reports?

Logs focus on detailed technical execution information, while reports organize test results and evidence for analysis and communication.

18. What should be considered for parallel reporting?

Reporting objects and test entries should be handled safely so that concurrent test executions do not overwrite or corrupt each other's information.

19. What is a report manager?

A report manager is a reusable framework component responsible for initializing, creating, configuring, and finalizing test reports.

20. What is the main benefit of HTML reporting?

The main benefit is converting raw automation execution information into a structured, readable, and shareable representation of test results and evidence.


79. Quick Reference Table

ConceptPurpose
HTML ReportBrowser-based test result presentation
TestNGTest execution and test management
ExtentReportsCustom HTML reporting
AllureInteractive test reporting
ExtentTestRepresents an individual test in ExtentReports
ExtentReportsManages report lifecycle
ExtentSparkReporterConfigures the HTML report output
extent.flush()Writes report information to the output
TakesScreenshotCaptures Selenium screenshots
ITestResultProvides TestNG test execution result information
ReportManagerCentralizes reporting functionality
CI/CDAutomates test execution and report publishing


80. Learning Roadmap for HTML Reports

  1. Understand TestNG test execution.
  2. Understand passed, failed, and skipped test states.
  3. Learn TestNG default reporting.
  4. Understand HTML report structure.
  5. Learn ExtentReports or another reporting solution.
  6. Create a basic HTML report.
  7. Add test information and descriptions.
  8. Add pass, fail, warning, and info logs.
  9. Capture Selenium screenshots.
  10. Attach screenshots to failed tests.
  11. Integrate reporting with Page Object Model.
  12. Integrate reporting with Data Providers.
  13. Add browser and environment metadata.
  14. Implement a reusable ReportManager.
  15. Handle parallel execution safely.
  16. Integrate reports with Maven.
  17. Integrate reports with Jenkins or another CI/CD system.
  18. Build a complete Selenium automation reporting framework.


81. Practical Exercises

  1. Create a TestNG test that generates a basic HTML report.
  2. Create separate passed and failed test cases.
  3. Add informational logs to every major Selenium step.
  4. Create a screenshot utility.
  5. Capture screenshots when tests fail.
  6. Attach screenshots to HTML reports.
  7. Add browser and environment information.
  8. Create a centralized ReportManager class.
  9. Integrate HTML reporting with Page Object Model.
  10. Integrate reporting with a Data Provider.
  11. Execute the framework through Maven.
  12. Generate separate smoke and regression reports.
  13. Run the framework through Jenkins and publish the generated report.
  14. Implement reporting for parallel Selenium execution.


82. Real-World Automation Reporting Architecture

                 Test Cases

                     |

                     v

                   TestNG

                     |

          +----------+----------+

          |                     |

          v                     v

      Selenium                Data

      WebDriver             Provider

          |                     |

          +----------+----------+

                     |

                     v

               Test Execution

                     |

          +----------+----------+

          |          |          |

          v          v          v

        Logs    Screenshots  Exceptions

          |          |          |

          +----------+----------+

                     |

                     v

               Report Manager

                     |

                     v

             Extent / Allure

                     |

                     v

               HTML Report

                     |

          +----------+----------+

          |                     |

          v                     v

       Local                  CI/CD

                                |

                                v

                         Jenkins / Pipeline

                                |

                                v

                         Team / Stakeholders


83. Summary

HTML Reports are an essential part of a professional Selenium automation framework because they convert raw test execution results into a structured and easy-to-understand format.

A good HTML report can show passed, failed, and skipped tests, execution duration, test steps, exceptions, screenshots, browser information, environment details, logs, and other test evidence.

TestNG provides the test execution foundation, while reporting libraries such as ExtentReports and Allure can be used to create richer and more customizable reports. Selenium screenshots can be attached to failed tests to provide visual evidence for debugging.

In advanced automation frameworks, HTML reporting can be integrated with Page Object Model, Data Providers, Maven, logging frameworks, parallel execution, Git, Jenkins, CI/CD pipelines, and reusable framework utilities.


84. Final Takeaway

HTML Reports make Selenium automation results readable, traceable, and shareable. A well-designed reporting system should clearly show what was tested, what passed, what failed, why it failed, and what evidence is available for investigation.

The ideal Selenium reporting workflow is:

TestNG

  |

  v

Selenium WebDriver

  |

  v

Test Execution

  |

  +---- Logs

  |

  +---- Assertions

  |

  +---- Screenshots

  |

  +---- Exceptions

  |

  v

Report Manager

  |

  v

HTML Report

  |

  v

CI/CD

  |

  v

Test Analysis


85. Course Resources

Learn more about Selenium automation, TestNG, reporting, frameworks, and practical automation testing:

Final Takeaway: HTML reporting is not only about displaying PASS or FAIL results. A professional reporting framework connects test execution, logs, screenshots, exceptions, test data, environment information, and CI/CD results into one organized source of test evidence.

whatsapp